'''

    解决问题的模型：方法，函数
        def  方法名(参数列表):   # 参数列表：可以自己定义传入多少个， 方法名称可以自己定义
            方法体，处理代码
            [return]


'''


# 特性：方法只能处理某个问题，单一性
# def getSum(num1,num2):
#     s = num1 + num2 # 将传进来的两个数据进行求和
#     return s  # 返回数据
#
# a = 6
# b = 5
#
# r1 = getSum(a,b)
#
# print(r1)
#

# 针对列表进行求和方法

# def getData(li):
#     s = 0
#     for i in li :
#         s =  s + i
#     return s

#
# list  = [1,2,3,4,5,6]
# data = getData(list)
#
# print(data)

def get_sum(*args):
    sum = 0
    for i in args:
        if i.isdigit():
            i = float(i)
            sum += i
        else:
            print('数据格式有误！')
    return sum


data1 = input('请输入4个数字，以逗号隔开：').split(',')
print('这4个数字的和是：', get_sum(data1[0], data1[1], data1[2], data1[3]))
print()


def get_sum_list(lisi):
    sum = 0
    for i in lisi:
        sum += i
    print('列表中数字的和是：', sum)


l1 = [1, 2, 3, 4, 5]
get_sum_list(l1)
print()


def NxN(num):
    for i in range(1, num + 1):
        for j in range(1, i + 1):
            print(j, '*', i, '=', j * i, end='\t')
        print()


NxN(9)
print()


def get_data(lisi, index):
    if index >= len(lisi) or index < 0:
        return -1
    else:
        return lisi[index]


l2 = input('请输入4个数字，以逗号隔开：').split(',')
index = int(input('请输入数字：'))
print('列表中对应数字的数据是：', get_data(l2, index))
print()


def get_sum_recursion(num):
    if num == 1:
        return 1
    else:
        return get_sum_recursion(num - 1) + num


print('1~300所有数的和是：', get_sum_recursion(300))
print()

l3 = ['小明', '小张', '小黄', '小杨']
l4 = ['小黄', '小李', '小王', '小杨', '小周']
l5 = ['小杨', '小张', '小吴', '小冯', '小周']


def get_total_num(*args):
    nset = set()
    for i in args:
        for j in i:
            nset.add(j)
    return len(nset)


print('部门员工总数为：', get_total_num(l3, l4, l5))
print()


def solution2(l3, l4, l5):
    count = 0
    names = []
    for i in l3:
        if i not in l4 and i not in l5:
            count += 1
            names.append(i)
    for i in l4:
        if i not in l3 and i not in l5:
            count += 1
            names.append(i)
    for i in l5:
        if i not in l3 and i not in l4:
            count += 1
            names.append(i)
    return [count, names]


info = solution2(l3, l4, l5)
print('只在一个部门存在的人的数量和对应的名字如下：')
print(info[0])
for i in info[1]:
    print(i, end='\t')
print()
print()

names2 = set()
for i in l3:
    if i not in info[1]:
        names2.add(i)
for i in l4:
    if i not in info[1]:
        names2.add(i)
for i in l5:
    if i not in info[1]:
        names2.add(i)
print('在两个部门以及以上的人员有如下：')
for i in names2:
    print(i, end='\t')
print()
print()


def NxN_reverse(num):
    while num > 0:
        for i in range(1, num + 1):
            print(i, '*', num, '=', i * num, end='\t')
        print()
        num -= 1


NxN_reverse(9)
